<?php
/***************************************************************************
 * 
 * Copyright (c) 2010 , Inc. All Rights Reserved
 * $Id$:PageController.php,2010/05/24 17:07:36 
 * 
 **************************************************************************/
 
 
 
/**
 * @file PageController.php
 * @author huqingping
 * @date 2010/05/24 17:07:36
 * @version 1.0 
 * @brief 
 *  
 **/

class PageController 
{
	var $request = null;
	var $response = null;
	var $debug = null;
	var $encoding = null;
	var $pages = array();

	protected function checkInput($rules,$inputs=array())
	{
		require_once 'validate/Validation.php';
		$ret = Validation::checkArray(empty($inputs)?$this->request->inputs:$inputs, $rules);
		$ret = array_diff($ret,array(true));
		if ($ret) {
			foreach($ret as $key=>$reason) {
				$this->set($key,$reason);
			}
			//有错误的字段值
			throw new Exception('hapn.u_input');
		}
	}
	protected function check($key,$rule)
	{
		require_once 'validate/Validation.php';
		$data = $this->get($key);
		return Validation::check($data, $rule);
	}

	function gets()
	{
		$keys = func_get_args();
		$ret = array();
		foreach($keys as $key) {
			$ret[$key] = $this->get($key);
		}
		return $ret;
	}

	function get($key,$default=null)
	{
		return $this->request->get($key,$default);
	}

	function getu($key,$default=null)
	{
		return $this->request->getu($key,$default);
	}

	function set($key,$value)
	{
		return $this->response->set($key,$value);
	}
	
	function rmset()
	{
		return call_user_func_array(array($this->response, 'rmset'), func_get_args());
	}

	function setView($template,$data=array())
	{
		return $this->response->setView($template,$data);
	}

}





/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */